/**
 * 车辆管理Api
 * @author 方礼爱
 * @version 1.0.0
 */
import http from '@/libs/api.request'
import $ from 'jquery';
import {  getToken } from '@/libs/util'
/**
 * 获取所有的车辆信息
 * @param {查询参数} search 
 */
export const getExamineCar=(search={})=>{
    search.status=0;
    return http.fetchGet('/cys/car/showCarList',search)
}

export const doExamineCar=(carId,status)=>{
    var params={
        carid:carId,
        status:status
    }
    return http.fetchPost('/cys/car/doExamineCar',params)
}

/** 
 * 获取正常车辆
*/
export const getNormalCars=(params={})=>{
    params=params||{};
    params.status=1;
    return http.fetchGet('/cys/car/showCarList',params)
}


/**
 * 获取所有车辆类型
 */
export const getCarTypes=(search={})=>{
    return http.fetchPost('/admin/cartype/search',search)
}

/**
 * 编辑车辆类型
 * @param {类型}} carType 
 */
export const editCarType=(carType)=>{
    return http.fetchPost('/admin/cartype/edit',carType)
}
/**
 * 删除车辆类型
 * @param {类型ID}} carTypeId 
 */
export const delCarType=(carTypeId)=>{
    return http.fetchPost('/admin/cartype/del/'+carTypeId,{})
}


export const  getAreaCarFreights= function (success,error){
        $.ajax({
            url:http.getBaseUrl()+'admin/cartype/getAreaCarFreights',//url路径
            type:'GET', //GET
            async:false, //或false,是否异步
            data:{//参数
            
            },
            timeout:5000, //超时时间
            dataType:'json', //返回的数据格式：
            beforeSend: function(request) {
                request.setRequestHeader("Authorization",getToken());
             },
            success:function(data,textStatus,jqXHR){
                success(data);
            },
            error:function(xhr,textStatus){
                 if(error!=null){
                     error(xhr);
                 }
            }
    });
}